home *** CD-ROM | disk | FTP | other *** search
- /*----------------------------------------------------------------------------
-
- listutil.c
-
- This reusable module contains miscellaneous List Manager
- utility routines.
-
- Copyright © 1994, Northwestern University.
-
- ----------------------------------------------------------------------------*/
-
- #include <stdio.h>
-
- #include "def.h"
- #include "listutil.h"
- #include "memutil.h"
- #include "drawutil.h"
-
-
-
- /*----------------------------------------------------------------------------
- InvalCell
-
- Invalidate a cell.
-
- Entry: theCell = the cell.
- theList = list handle.
- ----------------------------------------------------------------------------*/
-
- static void InvalCell (Cell theCell, ListHandle theList)
- {
- Rect visible, inval;
- short rViewTop, cellHeight;
-
- inval = (**theList).rView;
- rViewTop = inval.top;
- visible = (**theList).visible;
- cellHeight = (**theList).cellSize.v;
- inval.top = rViewTop + (theCell.v - visible.top) * cellHeight;
- inval.bottom = inval.top + cellHeight;
- InvalRect(&inval);
- }
-
-
-
- /*----------------------------------------------------------------------------
- SelectCellRange
-
- Quickly select or deselect all the cells in a range.
-
- Entry: select = true to select all, false to deselect all.
- first = first row to select.
- last = last row to select.
- theList = list handle.
- ----------------------------------------------------------------------------*/
-
- static void SelectCellRange (Boolean select, short first, short last,
- ListHandle theList)
- {
- short *p, *pEnd, visTop, visBot;
- Rect rView;
- Cell theCell;
- Boolean cellChanged;
- Point cellSize;
- GrafPtr port;
- char state;
-
- GetPort(&port);
- SetPort((**theList).port);
- rView = (**theList).rView;
- cellSize = (**theList).cellSize;
- visTop = (**theList).visible.top;
- visBot = (**theList).visible.bottom;
- SetPt(&theCell, 0, first);
- state = MyHGetState(theList);
- MyHLock(theList);
- p = (**theList).cellArray + first;
- pEnd = p + last - first + 1;
- while (p < pEnd) {
- if (select) {
- cellChanged = (*p & 0x8000) == 0;
- *p |= 0x8000;
- } else {
- cellChanged = (*p & 0x8000) != 0;
- *p &= 0x7fff;
- }
- if (cellChanged && theCell.v >= visTop && theCell.v <= visBot)
- InvalCell(theCell, theList);
- p++;
- theCell.v++;
- }
- MyHSetState(theList, state);
- SetPort(port);
- }
-
-
-
- /*----------------------------------------------------------------------------
- SelectOrDeselectAllListItems
-
- Quickly select or deselect all the items in a list.
-
- Entry: theList = list handle.
- select = true to select all, false to deselect all.
- ----------------------------------------------------------------------------*/
-
- void SelectOrDeselectAllListItems (ListHandle theList, Boolean select)
- {
- SelectCellRange(select, 0, (**theList).dataBounds.bottom - 1, theList);
- }
-
-
-
- /*----------------------------------------------------------------------------
- SelectSingleListItem
-
- Quickly select a single item in a list and deselect all the others.
-
- Entry: theList = list handle.
- theCell = item to be selected.
- ----------------------------------------------------------------------------*/
-
- void SelectSingleListItem (ListHandle theList, Cell theCell)
- {
- short *p, *pEnd, visTop, visBot;
- Rect rView;
- Cell tmpCell;
- Boolean cellChanged, setIt;
- Point cellSize;
- GrafPtr port;
- char state;
-
- GetPort(&port);
- SetPort((**theList).port);
- rView = (**theList).rView;
- cellSize = (**theList).cellSize;
- visTop = (**theList).visible.top;
- visBot = (**theList).visible.bottom;
- SetPt(&tmpCell, 0, 0);
- state = MyHGetState(theList);
- MyHLock(theList);
- p = (**theList).cellArray;
- pEnd = p + (**theList).dataBounds.bottom;
-
- if ((**theList).lActive && ((WindowPeek)(**theList).port)->hilited) {
-
- while (p < pEnd) {
- if (tmpCell.v == theCell.v) {
- cellChanged = (*p & 0x8000) == 0;
- setIt = true;
- } else {
- cellChanged = (*p & 0x8000) != 0;
- setIt = false;
- }
- if (cellChanged) {
- if (tmpCell.v >= visTop && tmpCell.v < visBot) {
- LSetSelect(setIt, tmpCell, theList);
- } else if (setIt) {
- *p |= 0x8000;
- } else {
- *p &= 0x7fff;
- }
- }
- p++;
- tmpCell.v++;
- }
-
- } else {
-
- while (p < pEnd) {
- if (tmpCell.v == theCell.v) {
- cellChanged = (*p & 0x8000) == 0;
- *p |= 0x8000;
- } else {
- cellChanged = (*p & 0x8000) != 0;
- *p &= 0x7fff;
- }
- if (cellChanged && tmpCell.v >= visTop && tmpCell.v <= visBot)
- InvalCell(tmpCell, theList);
- p++;
- tmpCell.v++;
- }
-
- }
-
- MyHSetState(theList, state);
- SetPort(port);
- }
-
-
-
- /*----------------------------------------------------------------------------
- ListHasSelectedCell
-
- Check to see if a list has at least one selected cell.
-
- Entry: theList = list handle.
-
- Exit: function result = true if list has at least one selected cell.
- ----------------------------------------------------------------------------*/
-
- Boolean ListHasSelectedCell (ListHandle theList)
- {
- Cell theCell;
-
- SetPt(&theCell, 0, 0);
- return LGetSelect(true, &theCell, theList);
- }
-
-
-
- /*----------------------------------------------------------------------------
- NumListItemsSelected
-
- Count the number of selected items in a list.
-
- Entry: theList = list handle.
-
- Exit: function result = number of items selected.
- ----------------------------------------------------------------------------*/
-
- short NumListItemsSelected (ListHandle theList)
- {
- short num = 0, *p, *pEnd;
-
- p = (**theList).cellArray;
- pEnd = p + (**theList).dataBounds.bottom;
- while (p < pEnd) {
- if (*p < 0) num++;
- p++;
- }
- return num;
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLScroll
-
- Scroll a list a specified number of rows.
-
- Entry: deltaRows = number of rows to scroll down (>0) or up (<0)
- theList = list handle.
-
- This function avoids an error in the List Manager LScroll function
- which causes crashes on some scrolls over 32K pixels. It only works on
- lists with 1 column.
- ----------------------------------------------------------------------------*/
-
- void MyLScroll (short deltaRows, ListHandle theList)
- {
- short numCellsToScroll;
- long numPixelsToScroll;
- GrafPtr port;
-
- GetPort(&port);
- SetPort((**theList).port);
- numCellsToScroll = deltaRows;
- if (numCellsToScroll < 0) numCellsToScroll = -numCellsToScroll;
- numPixelsToScroll = (long)numCellsToScroll * (long)(**theList).cellSize.v;
- if (numPixelsToScroll > 0x3fff) {
- LSetDrawingMode(false, theList);
- LScroll(0, deltaRows, theList);
- LSetDrawingMode(true, theList);
- InvalRect(&(**theList).rView);
- } else {
- LScroll(0, deltaRows, theList);
- }
- SetPort(port);
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLScrollCellIntoView
-
- Scroll a cell into view.
-
- Entry: theCell = cell.
- theList = list handle.
-
- This function avoids an error in the List Manager LAutoScroll function
- which causes crashes on some scrolls over 32K pixels. It only works on
- lists with 1 column.
- ----------------------------------------------------------------------------*/
-
- void MyLScrollCellIntoView (Cell theCell, ListHandle theList)
- {
- short top, bottom;
- Rect visible;
-
- visible = (**theList).visible;
- top = visible.top;
- bottom = visible.bottom;
- if (theCell.v < top) {
- MyLScroll(theCell.v - top, theList);
- } else if (theCell.v == bottom) {
- if (NumListItemsSelected(theList) == 1) {
- MyLScroll(bottom - top, theList);
- } else {
- MyLScroll(1, theList);
- }
- } else if (theCell.v > bottom) {
- MyLScroll(theCell.v - bottom + 1, theList);
- }
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLAutoScroll
-
- Scroll the first selected cell into view.
-
- Entry: theList = list handle.
-
- This function avoids an error in the List Manager LAutoScroll function
- which causes crashes on some scrolls over 32K pixels. It only works on
- lists with 1 column.
- ----------------------------------------------------------------------------*/
-
- void MyLAutoScroll (ListHandle theList)
- {
- Cell theCell;
-
- SetPt(&theCell, 0, 0);
- if (!LGetSelect(true, &theCell, theList)) return;
- MyLScrollCellIntoView(theCell, theList);
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLScrollCenter
-
- Scroll a cell into the center of the visible part of the list, if
- necessary.
-
- Entry: theCell = cell.
- theList = list handle.
- ----------------------------------------------------------------------------*/
-
- void MyLScrollCenter (Cell theCell, ListHandle theList)
- {
- short top, bottom, visHeight;
- Rect visible;
-
- visible = (**theList).visible;
- top = visible.top;
- bottom = visible.bottom;
- if (theCell.v >= top && theCell.v < bottom) return;
- visHeight = bottom - top;
- MyLScroll(theCell.v - top - (visHeight >>1), theList);
- }
-
-
-
- /*----------------------------------------------------------------------------
- BuildListSelectedCellsDragRegion
-
- Build a drag region for the selected cells in a list.
-
- Entry: theList = handle to list.
-
- Exit: *dragRgn = handle to drag region.
- ----------------------------------------------------------------------------*/
-
- void BuildListSelectedCellsDragRegion (ListHandle theList, RgnHandle *dragRgn)
- {
- RgnHandle rgn;
- Cell curCell;
- Rect cellRect;
- Rect visible;
- GrafPtr port;
-
- GetPort(&port);
- SetPort((**theList).port);
- visible = (**theList).visible;
- rgn = NewRgn();
- OpenRgn();
- SetPt(&curCell, 0, visible.top);
- while (LGetSelect(true, &curCell, theList) && curCell.v < visible.bottom) {
- LRect(&cellRect, curCell, theList);
- LocalToGlobalRect(&cellRect);
- FrameRect(&cellRect);
- curCell.v++;
- }
- CloseRgn(rgn);
- SetPort(port);
- OutlineRegion(rgn);
- *dragRgn = rgn;
- }
-
-
-
- /*----------------------------------------------------------------------------
- DrawListDividingLIne
-
- Draw or erase a horizontal dividing line in a list.
-
- Entry: theList = handle to the list.
- destRow = row number of cell following the line to be
- drawn or erased.
- ----------------------------------------------------------------------------*/
-
- void DrawListDividingLine (ListHandle theList, short destRow)
- {
- GrafPtr port, listPort;
- PenState savePen;
- Rect clipRect;
- static RgnHandle savedClip = nil;
- short v;
-
- listPort = (**theList).port;
-
- GetPort(&port);
- GetPenState(&savePen);
- SetPort(listPort);
- if (savedClip == nil) savedClip = NewRgn();
- GetClip(savedClip);
-
- v = (**theList).cellSize.v * (destRow - (**theList).visible.top) +
- (**theList).rView.top - 1;
-
- clipRect = (**theList).rView;
- ClipRect(&clipRect);
- PenMode(patXor);
- PenPat(&qd.black);
- PenSize(2, 2);
- MoveTo((**theList).rView.left, v);
- LineTo((**theList).rView.right - 2, v);
-
- SetClip(savedClip);
- SetPenState(&savePen);
- SetPort(port);
- }
-
-
-
- /*----------------------------------------------------------------------------
- ListDestinationRow
-
- Compute the destination row for a list given a location in
- the list.
-
- Entry: theList = handle to the list.
- where = location in list in local coordinates.
-
- Exit: function result = destination row number.
- ----------------------------------------------------------------------------*/
-
- short ListDestinationRow (ListHandle theList, Point where)
- {
- short cellHeight, destRow, numCells;
-
- cellHeight = (**theList).cellSize.v;
- numCells = (**theList).dataBounds.bottom;
- destRow = (where.v - (**theList).rView.top + (cellHeight >> 1)) / cellHeight +
- (**theList).visible.top;
- if (destRow < 0) destRow = 0;
- if (destRow > numCells) destRow = numCells;
- return destRow;
- }
-
-
-
- /*----------------------------------------------------------------------------
- MoveSelectedListCells
-
- Move the selected cells in a list to a new location.
-
- Entry: theList = handle to list record
- destRow = row number of cell following destination.
-
- Exit: *changed = true if the cell order was changed.
-
- The cell data cannot exceed 256 bytes in length.
- ----------------------------------------------------------------------------*/
-
- void MoveSelectedListCells (ListHandle theList, short destRow, Boolean *changed)
- {
- short count;
- Cell oldCell, newCell;
- short dataLen, firstRow, prevRow, index;
- Boolean contiguous = true;
- Rect rView;
- char cellData[256];
- GrafPtr port;
-
- GetPort(&port);
- SetPort((**theList).port);
-
- /* Count the number of cells to be moved. Also check to see if the
- cells being moved are contiguous. */
-
- count = 0;
- SetPt(&oldCell, 0, 0);
- while (LGetSelect(true, &oldCell, theList)) {
- if (count == 0) firstRow = oldCell.v;
- if (contiguous && count > 0 && oldCell.v != prevRow + 1) contiguous = false;
- prevRow = oldCell.v;
- count++;
- oldCell.v++;
- }
-
- /* If the cells being moved are contiguous, check to see if there is no
- change. If not, just return. */
-
- if (contiguous && firstRow <= destRow && destRow <= firstRow + count) {
- *changed = false;
- SetPort(port);
- return;
- }
-
- /* Move the selected cells to the new location one at a time. */
-
- LSetDrawingMode(false, theList);
- SetPt(&oldCell, 0, 0);
- newCell.h = 0;
- index = 0;
- while (LGetSelect(true, &oldCell, theList)) {
- dataLen = 256;
- LGetCell(cellData, &dataLen, oldCell, theList);
- LDelRow(1, oldCell.v, theList);
- if (oldCell.v < destRow) destRow--;
- newCell.v = destRow + index;
- LAddRow(1, newCell.v, theList);
- LSetCell(cellData, dataLen, newCell, theList);
- index++;
- }
-
- /* Select the new cells. */
-
- SetPt(&newCell, 0, destRow);
- while (count--) {
- MyLSetSelect(true, newCell, theList);
- newCell.v++;
- }
-
- /* Redraw the list. */
-
- MyLAutoScroll(theList);
- rView = (**theList).rView;
- InvalRect(&rView);
- LSetDrawingMode(true, theList);
- *changed = true;
-
- SetPort(port);
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLSetSelect
-
- Select or deselect a cell.
-
- Entry: setIt = true to select, false to deselect.
- theCell = the cell.
- theList = handle to list record
- ----------------------------------------------------------------------------*/
-
- void MyLSetSelect (Boolean setIt, Cell theCell, ListHandle theList)
- {
- GrafPtr port;
- short *cellArray;
- Boolean oldSel;
-
- GetPort(&port);
- SetPort((**theList).port);
- cellArray = (**theList).cellArray;
- oldSel = cellArray[theCell.v] < 0;
- LSetSelect(setIt, theCell, theList);
- if (!(**theList).lActive && oldSel != setIt) LDraw(theCell, theList);
- SetPort(port);
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLClick
-
- Process a mouse-down in a list.
-
- Entry: localPt = click location in local coords.
- modifiers = keyboard modifiers from event record.
- theList = handle to list record.
-
- Exit: function result = true if double-click.
-
- This function is more than a bit goofy. It is used when you permit
- clicks on list items in inactive windows. It sets the list's "lActive"
- flag to true to fool the List Manager's LClick function into doing
- cell selection and deselection. Your LDEF must be prepared to do
- proper hiliting of cells in inactive windows.
- ----------------------------------------------------------------------------*/
-
- Boolean MyLClick (Point localPt, short modifiers, ListHandle theList)
- {
- Boolean lActive, result;
-
- lActive = (**theList).lActive;
- (**theList).lActive = true;
- result = LClick(localPt, modifiers, theList);
- (**theList).lActive = lActive;
- return result;
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLActivate
-
- Activate or deactivate a list.
-
- Entry: act = true to activate list, false to deactivate.
- theList = handle to list record.
- ----------------------------------------------------------------------------*/
-
- void MyLActivate (Boolean act, ListHandle theList)
- {
- ControlHandle vScroll, hScroll;
- Rect visible, vScrollRect, hScrollRect;
- Cell theCell;
-
- if ((**theList).lActive == act) return;
- (**theList).lActive = act;
-
- vScroll = (**theList).vScroll;
- hScroll = (**theList).hScroll;
- if (vScroll != nil) vScrollRect = (**vScroll).contrlRect;
- if (hScroll != nil) hScrollRect = (**hScroll).contrlRect;
- if (act) {
- if (vScroll != nil) {
- (**vScroll).contrlVis = 255;
- InvalRect(&vScrollRect);
- }
- if (hScroll != nil) {
- (**hScroll).contrlVis = 255;
- InvalRect(&hScrollRect);
- }
- } else {
- if (vScroll != nil) {
- (**vScroll).contrlVis = 0;
- InvalRect(&vScrollRect);
- }
- if (hScroll != nil) {
- (**hScroll).contrlVis = 0;
- InvalRect(&hScrollRect);
- }
- }
-
- visible = (**theList).visible;
- theCell.h = 0;
- for (theCell.v = visible.top; theCell.v < visible.bottom; theCell.v++)
- if ((**theList).cellArray[theCell.v] < 0) InvalCell(theCell, theList);
- }
-
-
-
- /*----------------------------------------------------------------------------
- MyLNew
-
- Create a list.
-
- Entry: rView = pointer to view rectangle.
- dataBounds = pointer to data bounds rectangle.
- cSize = cell size.
- theProc = resource id of LDEF.
- theWindow = pointer to window containing the list.
- drawIt = true to draw, false to delay drawing.
- hasGrow = true if has size box.
- scrollHoriz = true if has horizontal scroll bar.
- scrollVert = true if has vertical scroll bar.
-
- Exit: function result = handle to list record.
- ----------------------------------------------------------------------------*/
-
- ListHandle MyLNew (Rect *rView, Rect *dataBounds, Point cSize, short theProc,
- WindowPtr theWindow, Boolean drawIt, Boolean hasGrow,
- Boolean scrollHoriz, Boolean scrollVert)
- {
- ListHandle theList;
- ControlHandle hScroll, vScroll;
-
- theList = LNew(rView, dataBounds, cSize, theProc, theWindow, drawIt, hasGrow,
- scrollHoriz, scrollVert);
- if (theWindow != FrontWindow()) {
- (**theList).lActive = false;
- if (scrollHoriz) {
- hScroll = (**theList).hScroll;
- (**hScroll).contrlVis = 0;
- }
- if (scrollVert) {
- vScroll = (**theList).vScroll;
- (**vScroll).contrlVis = 0;
- }
- }
- return theList;
- }
-
-
-
- /*----------------------------------------------------------------------------
- PtInListCell
-
- Determine whether or not a point is in a list cell.
-
- Entry: where = point in local coords.
- theList = handle to list record.
-
- Exit: function result = true if point is in a list cell.
- ----------------------------------------------------------------------------*/
-
- Boolean PtInListCell (Point where, ListHandle theList)
- {
- Rect rView, visible;
- short numCells, cellHeight;
-
- rView = (**theList).rView;
- if (!PtInRect(where, &rView)) return false;
- visible = (**theList).visible;
- numCells = (**theList).dataBounds.bottom;
- if (visible.bottom < numCells) return true;
- cellHeight = (**theList).cellSize.v;
- return where.v - rView.top <= cellHeight * (numCells - visible.top);
- }
-
-
-
- /*----------------------------------------------------------------------------
- GetFirstSelectedCell
-
- Get the first selected cell in a list.
-
- Entry: theList = list handle.
-
- Exit: function result = row number of first selected cell, or
- -1 if no selected cells.
- ----------------------------------------------------------------------------*/
-
- short GetFirstSelectedCell (ListHandle theList)
- {
- Cell theCell;
-
- SetPt(&theCell, 0, 0);
- if (LGetSelect(true, &theCell, theList)) {
- return theCell.v;
- } else {
- return -1;
- }
- }
-
-
-
- /*----------------------------------------------------------------------------
- GetLastSelectedCell
-
- Get the last selected cell in a list.
-
- Entry: theList = list handle.
-
- Exit: function result = row number of last selected cell, or
- -1 if no selected cells.
- ----------------------------------------------------------------------------*/
-
- short GetLastSelectedCell (ListHandle theList)
- {
- short *cellArray, *p;
-
- cellArray = (**theList).cellArray;
- p = cellArray + (**theList).dataBounds.bottom - 1;
- while (p >= cellArray) {
- if (*p < 0) return p - cellArray;
- p--;
- }
- return -1;
- }
-
-
-
- /*----------------------------------------------------------------------------
- CellSelected
-
- Determine whether a cell is selected.
-
- Entry: theCell = cell.
- theList = list handle.
-
- Exit: function result = true if cell selected.
- ----------------------------------------------------------------------------*/
-
- static Boolean CellSelected (Cell theCell, ListHandle theList)
- {
- return *((**theList).cellArray + theCell.v) < 0;
- }
-
-
-
- /*----------------------------------------------------------------------------
- ListArrowKey
-
- Handle an up or down arrow key for a list window.
-
- Entry: theChar = upArrow or downArrow.
- modifiers = modifiers field from event record.
- theList = handle to list record.
- prevEvent = pointer to previous event.
-
- Exit: function result = error code.
- *scrollIntoView = cell which should be scrolled into view.
- ----------------------------------------------------------------------------*/
-
- void ListArrowKey (char theChar, short modifiers, ListHandle theList,
- EventRecord *prevEvent, Cell *scrollIntoView)
- {
- Boolean shift, command, option;
- char prevChar;
- short prevModifiers;
- Boolean prevWasArrowKey, shiftArrowSequence;
- short firstSelected, lastSelected;
- short numCells;
- Cell theCell = {0, 0};
- Rect visible;
- short pageHeight;
- static short anchor;
- static short prevFloatingEnd;
-
- numCells = (**theList).dataBounds.bottom;
- if (numCells == 0) goto exit;
- firstSelected = GetFirstSelectedCell(theList);
- lastSelected = GetLastSelectedCell(theList);
- shift = (modifiers & shiftKey) != 0;
- command = (modifiers & cmdKey) != 0;
- option = (modifiers & optionKey) != 0;
- prevChar = prevEvent->message & 0xff;
- prevModifiers = prevEvent->modifiers;
- prevWasArrowKey = (prevEvent->what == keyDown || prevEvent->what == autoKey) &&
- (prevChar == upArrow || prevChar == downArrow);
- shiftArrowSequence = shift && prevWasArrowKey &&
- (prevModifiers & shiftKey) != 0;
-
- if (shift && !shiftArrowSequence)
- anchor = theChar == upArrow ? firstSelected : lastSelected;
-
- if (shiftArrowSequence) {
- theCell.v = prevFloatingEnd;
- } else {
- theCell.v = theChar == upArrow ? firstSelected : lastSelected;
- }
-
- if (!command) {
-
- if (theCell.v < 0) {
- theCell.v = 1;
- } else if (theChar == upArrow) {
- theCell.v--;
- if (shiftArrowSequence && theCell.v < anchor)
- while (theCell.v > 0 && CellSelected(theCell, theList))
- theCell.v--;
- } else {
- theCell.v++;
- if (shiftArrowSequence && theCell.v > anchor)
- while (theCell.v < numCells - 1 && CellSelected(theCell, theList))
- theCell.v++;
- }
-
- } else if (!option && command) {
-
- visible = (**theList).visible;
- pageHeight = visible.bottom - visible.top - 1;
- if (theChar == upArrow) {
- if (theCell.v == visible.top) {
- theCell.v -= pageHeight;
- } else {
- theCell.v = visible.top;
- }
- } else {
- if (theCell.v == visible.bottom - 1) {
- theCell.v += pageHeight;
- } else {
- theCell.v = visible.bottom - 1;
- }
- }
-
- } else if (option && command) {
-
- theCell.v = theChar == upArrow ? 0 : numCells-1;
-
- }
-
- if (theCell.v < 0) {
- theCell.v = 0;
- } else if (theCell.v >= numCells) {
- theCell.v = numCells - 1;
- }
-
- if (!shift || anchor < 0) {
- SelectSingleListItem(theList, theCell);
- } else if (!shiftArrowSequence) {
- if (anchor <= theCell.v) {
- SelectCellRange(true, anchor, theCell.v, theList);
- } else {
- SelectCellRange(true, theCell.v, anchor, theList);
- }
- } else {
- if (anchor <= prevFloatingEnd && prevFloatingEnd < theCell.v) {
- SelectCellRange(true, prevFloatingEnd + 1, theCell.v, theList);
- } else if (anchor <= theCell.v && theCell.v < prevFloatingEnd) {
- SelectCellRange(false, theCell.v + 1, prevFloatingEnd, theList);
- } else if (theCell.v < prevFloatingEnd && prevFloatingEnd <= anchor) {
- SelectCellRange(true, theCell.v, prevFloatingEnd - 1, theList);
- } else if (prevFloatingEnd < theCell.v && theCell.v <= anchor) {
- SelectCellRange(false, prevFloatingEnd, theCell.v - 1, theList);
- } else if (prevFloatingEnd <= anchor && anchor <= theCell.v) {
- SelectCellRange(false, prevFloatingEnd, anchor - 1, theList);
- SelectCellRange(true, anchor, theCell.v, theList);
- } else if (theCell.v <= anchor && anchor <= prevFloatingEnd) {
- SelectCellRange(true, theCell.v, anchor, theList);
- SelectCellRange(false, anchor + 1, prevFloatingEnd, theList);
- }
- }
- prevFloatingEnd = theCell.v;
-
- exit:
-
- *scrollIntoView = theCell;
- }
-
-
-
- /*----------------------------------------------------------------------------
- SetListClickLoop
-
- Set a click loop function for a list.
-
- Entry: theList = handle to list record.
- clickLoopUPP = click loop UPP.
-
- This function contains a hack by Dave Radcliffe of Apple DTS to
- solve a problem with native mode List Manager click loop functions.
- The problem is that the 68K List Manager expects the Boolean function
- result in the Z bit in the condition code register, but the Mixed
- Mode Manager doesn't set this bit correctly. The hack uses a 68K
- wrapper in native mode to set the Z bit.
-
- This function should be called to set a click loop function
- immediately before calling LClick or MyLClick.
- ----------------------------------------------------------------------------*/
-
- void SetListClickLoop (ListHandle theList, ListClickLoopUPP clickLoopUPP)
- {
- #ifdef powerc
-
- #pragma options align=mac68k
- static struct clickLoopGlue {
- long move; /* movea.l clickLoopUPP,a0 */
- short jsr; /* jsr (a0) */
- short tst; /* tst.b d0 */
- short rts; /* rts */
- ListClickLoopUPP clickLoopUPP; /* the UPP */
- } clickLoop68K = {
- 0x207A0008,
- 0x4E90,
- 0x4A00,
- 0x4E75,
- 0
- };
- #pragma options align=reset
-
- clickLoop68K.clickLoopUPP = clickLoopUPP;
- (**theList).lClickLoop = (ListClickLoopUPP)&clickLoop68K;
-
- #else
-
- (**theList).lClickLoop = clickLoopUPP;
-
- #endif
- }